package com.fate.system.utils;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

public class PdfUtil {

  public static int getNumberOfPages(MultipartFile file) throws IOException {
    try (InputStream inputStream = file.getInputStream();
        PDDocument document = PDDocument.load(inputStream)) {
      return document.getNumberOfPages();
    }
  }
}
